package com.woniuxy.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.woniuxy.pojo.User;
import com.woniuxy.service.UserService;

@RestController
@RequestMapping("/test")
public class JSONController {

	@Autowired
	private UserService userSerivice;
	
	@RequestMapping("/getString")
	//@ResponseBody
	public String getString(){
		
		
		return "hello";
	}
	
	@RequestMapping("/getDate")
	//@ResponseBody
	public Date getDate(){
		
		
		return new Date();
	}
	
	@RequestMapping("/getUser")
	//@ResponseBody
	public User getUser(){
		
		return userSerivice.getAllUsers().get(0);
		
	}
	
	@RequestMapping("/getList")
	//@ResponseBody
	public List<User> getList(){
		
		return userSerivice.getAllUsers();
		
	}
	
	@RequestMapping("/getMap")
	//@ResponseBody
	public Map<String,Object> getMap(){
		
		Map<String,Object> m=new HashMap<String,Object>();
		m.put("pages", 3);
		m.put("totalCount", 10);
		m.put("data", userSerivice.getAllUsers());
		return m;
		
	}
	
	@RequestMapping("/getRequest")
	
	public User getRequest(User user){
		
	
		return user;
		
	}
	
	@RequestMapping("/getRequest1")
	
	public User getRequest1(@RequestBody User user){
		
	
		return user;
		
	}
	
	@RequestMapping("/getRequest2")
	
	public User getRequest2(User user){
		
	
		return user;
		
	}
}
